package de.fhhof.robot.control.app;

import java.io.*;
import java.math.BigInteger;
import java.util.*;

import de.fhhof.robot.control.common.CommonConstants;

public class ApplicationConfigration{
 
  public static void loadConfigration(){
    try{
    	//String path = new java.io.File(".").getCanonicalPath();
    	//System.out.println(path);
    	File f = new File(".\\conf.properties");
    	System.out.println("Loading Configuration file from: "+f.getCanonicalPath());
          if(f.exists()){
        	  
          Properties pro = new Properties();
        
          FileInputStream in = new FileInputStream(f);
          //InputStream is = pro.getResourceAsStream(f);
          pro.load(in);
        
          // System.out.println("All key are given: " + pro.keySet());
        
         
          String JSAP_HOST = pro.getProperty("JSAP_HOST");
          CommonConstants.JSAP_HOST=JSAP_HOST;
                 
          String  v1= pro.getProperty("ROBOT_PORT");
          int robart_port_value=Integer.parseInt(v1);
          CommonConstants.ROBOT_PORT=robart_port_value;
          
          String v2 = pro.getProperty("SOCKET_RECONNECT_INTERVAL");
          int socket_reconnect_interval_value=Integer.parseInt(v2);
          CommonConstants.SOCKET_RECONNECT_INTERVAL=socket_reconnect_interval_value;
        
          
          String v3 = pro.getProperty("STORAGE_PORT");
          int storage_port_value=Integer.parseInt(v3); 
          CommonConstants.STORAGE_PORT =storage_port_value;
          
          String v4 = pro.getProperty("JSAP_PORT");
          int jsap_port_value=Integer.parseInt(v4);
          CommonConstants.SOCKET_RECONNECT_INTERVAL=jsap_port_value;
          
          String v5 = pro.getProperty("SOCKET_TIMEOUT_PERIOD");
          int socket_timeout_period_value=Integer.parseInt(v5);
          CommonConstants.SOCKET_RECONNECT_INTERVAL=socket_timeout_period_value;
          
          }
       
      
    }
    catch(IOException e){
    System.out.println(e.getMessage());
    }
  }
}